import { createRouter, createWebHistory } from 'vue-router'
import admin from '@/layouts/admin.vue'
import index from '@/views/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path:'/',
      component:admin,
      children:[
          {
            path:'/',
            component:index
          },
          {
            path:'/publish',
            component:()=>import('@/views/publishPost.vue')
          },
          {
            path: '/post/:id',
            name: 'PostDetail',
            component:()=>import('@/views/detail.vue'),
            props: true
          },
          {
            path:'/change',
            name:'Change',
            component:()=>import('@/views/changeinfo.vue')
          },
          {
            path:'/userhome',
            name:'Userhome',
            component:()=>import('@/views/userhome.vue')
          },
          {
            path:'/mylike',
            name:'Mylike',
            component:()=>import('@/views/mylike.vue')
          },
          {
            path:'/myfav',
            name:'Myfav',
            component:()=>import('@/views/myfav.vue')
          },
          {
            path: '/changepost/:id',
            name: 'Changepost',
            component:()=>import('@/views/changpost.vue')
          }


      ]
    },
    {
      path:'/login',
      component:()=>import('@/views/login.vue')
    },
    {
      path:'/register',
      component:()=>import('@/views/register.vue')
    }
  ]
})

export default router
